import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/HomeBox/Home.vue'
import userUtils from "../utils/userUtils"

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta:{
      isShowTabbar:true
    }
  },
  {
    path: '/classfiy',
    name: 'classfiy',
    component: () => import('../views/classfiy/classfiy.vue'),
    meta:{
      isShowTabbar:true
    }
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import('../views/cart/cart.vue'),
    meta:{
      isShowTabbar:true
    }
  },
  {
    path: '/user',
    name: 'user',
    component: () => import('../views/user/user.vue'),
    meta:{
      isShowTabbar:true
    }
  },
  {
    path: '/allBar',
    name: 'allBar',
    component: () => import('../views/allBar.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/details',
    name: 'details',
    component: () => import('../views/details.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/sigin',
    name: 'sigin',
    component: () => import('../views/HomeBox/sigin.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/certificate',
    name: 'certificate',
    component: () => import('../views/HomeBox/certificate.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/special',
    name: 'special',
    component: () => import('../views/HomeBox/special.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/zhuanlan',
    name: 'zhuanlan',
    component: () => import('../views/HomeBox/zhuanlan.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/classfyDetails',
    name: 'classfyDetails',
    component: () => import('../views/classfiy/classfyDetails.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/goods_details',
    name: 'goods_details',
    component: () => import('../views/goods_details.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/user/login.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/user/register.vue'),
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/pingjia',
    name: 'pingjia',
    component: () => import('../views/user/pingjia.vue'),
    beforeEnter:(to,from,next)=>{
      if(userUtils.isLogin()){
        next()
      }else{
        next("login")
      }
    },
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/dizhi',
    name: 'dizhi',
    component: () => import('../views/user/dizhi.vue'),
    beforeEnter:(to,from,next)=>{
      if(userUtils.isLogin()){
        next()
      }else{
        next("login")
      }
    },
    meta:{
      isShowTabbar:false
    }
  },
  {
    path: '/dingdan',
    name: 'dingdan',
    component: () => import('../views/user/dingdan.vue'),
    beforeEnter:(to,from,next)=>{
      if(userUtils.isLogin()){
        next()
      }else{
        next("login")
      }
    },
    meta:{
      isShowTabbar:false
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
